<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">

  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="http://www.kaka996.com/" class="nav-link" target="_blank">开发者网站</a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="http://bbs.kaka996.com/" class="nav-link" target="_blank">社区</a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="http://doc.kaka996.com/" class="nav-link" target="_blank">文档</a>
      </li>
    </ul>

    <!-- SEARCH FORM -->
    <!-- <form class="form-inline ml-3">
      <div class="input-group input-group-sm">
        <input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
        <div class="input-group-append">
          <button class="btn btn-navbar" type="submit">
            <i class="fas fa-search"></i>
          </button>
        </div>
      </div>
    </form> -->

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- <li class="nav-item">
        <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#">
          <i class="fas fa-th-large"></i>
        </a>
      </li> -->
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-light-primary elevation-4">
    <!-- Brand Logo -->
    <a href="#" class="brand-link">
      <img src="/public/dist/img/logo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
           style="opacity: .8">
      <span class="brand-text font-weight-light">Dapps store</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      <div class="user-panel mt-3 pb-3 mb-3 d-flex">
          <div class="image">
            <img id="user_avatar" src="/public/dist/img/avatar-default.jpg" class="img-circle elevation-2" alt="User Image">
          </div>
          <div id="user_info" class="info">
            <a href="/html/v1/login">登录</a> <a href="#">/</a> <a href="/html/v1/register">注册</a>
          </div>
      </div>

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
          <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
          <li class="nav-item">
            <a href="/html/v1/store/quick"  <% if (navigation === 'quick') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-cubes"></i>
              <p>
                快速使用
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/list"  <% if (navigation === 'store') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-tachometer-alt"></i>
              <p>
                商店
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/myapp" <% if (navigation === 'my_app') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-th"></i>
              <p>
                我的
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/chat" <% if (navigation === 'chat') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-comments"></i>
              <p>
                讨论
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/appupdate" <% if (navigation === 'appupdate') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-th"></i>
              <p>
                升级
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/help" <% if (navigation === 'help') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-question"></i>
              <p>
                帮助
              </p>
            </a>
          </li>
          <li class="nav-item">
            <a href="/html/v1/store/version" <% if (navigation === 'version') { %> class="nav-link active" <% } else { %> class="nav-link" <% } %> >
              <i class="nav-icon fas fa-th"></i>
              <p id="sys_version">
                版本信息
              </p>
            </a>
          </li>
          <!-- <li class="nav-item">
            <a href="#" class="nav-link">
              <i class="nav-icon fas fa-th"></i>
              <p>
                开发者
              </p>
            </a>
          </li> -->
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <script>
    $(document).ready(function(){

      // 用户信息
      var userInfo=localStorage.getItem("user_info");
      if (userInfo) {
        var userInfo = JSON.parse(userInfo);
        $("#user_avatar").attr("src","/public/dist/img/user2-160x160.jpg");
        var user_info_content = '<a href="#" class="d-block">' + userInfo.username + '</a>';
        $("#user_info").html(user_info_content);
      }

      // 检查是否有新的版本
      var url = "/api/v1/store/check_sys_version";
      $.get(url,function(result){
        var versionInfo = result.data;
        if (versionInfo.has_new_version === true) {
          $("#sys_version").text("发现新版本");
        }
      });

    });
  </script>